package org.overtheair.say.domain;

import org.openintents.intents.WikitudePOI;
import org.overtheair.say.common.GlobalBag;

public class DataMovie extends DataAncestor {

	// ************************************************************************
	// ctor
	// ************************************************************************
	public DataMovie() {
	}
	
	public DataMovie(String jsonStrem)
	{
		buildFromJSON(jsonStrem);
	}
	
	// ************************************************************************
	// properties
	// ************************************************************************
	public long id;
	public static final String PROP_ID = "id";
	
	public String title;
	public static final String PROP_NAME = "title";
	public String cinemaname;
	public static final String PROP_CINEMANAME = "cinemaname";

	public String imageurl;
	public static final String PROP_IMAGEURL = "imageurl";
	
	public double location_latitude;
	public static final String PROP_LOCATION_LATITUDE = "latitude";
	public double location_longitude;
	public static final String PROP_LOCATION_LONGITUDE = "longitude";



	// ************************************************************************
	// interface implementation
	// ************************************************************************

	@Override
	public void buildFromJSON(String jsonStream)
	{
		//split row fields
		String[] fields = jsonStream.split("###");
		
		title = fields[4];
		cinemaname = fields[2];
		imageurl = fields[3];
		location_latitude = new Double(fields[0]);
		location_longitude = new Double(fields[1]);
	}

	@Override
	public boolean isDataValid() {
		return id == GlobalBag.INVALID_DATA_KEY_LONG;
	}

	@Override
	public WikitudePOI toWikitudePOI()
	{
		WikitudePOI poi;

		poi = new WikitudePOI(
				location_latitude,
				location_longitude,
				1,
				title,
				cinemaname,
				null,
				imageurl
			);
		return poi;
	}

}
